<!--
    @Title: index
    @Author  dudalei
    @Package
    @Date  2025/5/9 21:23
    @description:
-->
<script setup lang="ts">
import Amap from './Amap.vue'
import Three from './Three.vue'
import Merge from './Merge.vue'

import { AmapAndThree, AmapAndThreeInjectKey } from '@/components/AmapThree/index.ts'
import { onBeforeUnmount, provide } from 'vue'
const mapCenter = [121.5, 31.24]
const mapStore = new AmapAndThree()
provide(AmapAndThreeInjectKey, mapStore)
onBeforeUnmount(() => {
  // 这里执行销毁方法 threejs 销毁自己看官网写这里只是写个demo
  if (mapStore.map.value) {
    mapStore.map.value.destroy()
  }
})
</script>

<template>
  <Amap :center="mapCenter"></Amap>
  <Three></Three>
  <Merge :center="mapCenter"></Merge>
  <slot></slot>
</template>

<style scoped></style>
